<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="${request.contextPath}/statics/login/css/common.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/login/css/index.css">
     <link rel="stylesheet" href="${request.contextPath}/statics/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/AdminLTE.min.css">
    
    <script src="${request.contextPath}/statics/login/js/jquery-1.11.0.min.js"></script>
    <title>系统登录</title>
</head>

<body>
<div class="login-box" id="rrapp" v-cloak>
    <div id="loginbg" class="loginbg">
        <img src="${request.contextPath}/statics/login/images/bg.jpg" />
    </div>
    <div class="loginblock">
        <div class="webinfocol">
            <div class="weblogo">
            </div>
        </div>
        <div class="logincol">
            <h2>用户登录</h2>
             <div v-if="error" class="alert alert-danger alert-dismissible"> 
        		<h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-triangle"></i> {{errorMsg}}</h4>
      		</div>
            <ul class="loginform">
                <li><div class="iptitem user"><span class="icon"></span>
                		<input type="text"  v-model="username" placeholder="请输入用户名" />
                	</div>
                </li>
                <li><div class="iptitem pwd"><span class="icon"></span>
                		<input type="password" class="form-control"  v-model="password" placeholder="请输入密码" />
                	</div>
                </li>
                <li><div class="iptitem validate"><span class="icon"></span>
                	 	<input type="text" class="form-control" v-model="captcha" @keyup.enter="login" placeholder="请输入验证码">
                	</div>
                	<img title="如果看不清楚，请单击图片刷新！" class="validateimg" :src="src" @click="refreshCode">
                	</li>
                <li class="btnbar">
                	<button type="button" class="btnlogin" @click="login">登录</button>
                </li>
            </ul>
        </div>
    </div>
    </div>
    <script src="${request.contextPath}/statics/login/js/jquery.placeholder.min.js"></script>
    <script src="${request.contextPath}/statics/login/js/index.js"></script>
    <script src="${request.contextPath}/statics/libs/vue.min.js"></script>

    <script type="text/javascript">
var vm = new Vue({
	el:'#rrapp',
	data:{
		username: '',
		password: '',
		captcha: '',
		error: false,
		errorMsg: '',
		src: 'captcha.jpg'
	},
	beforeCreate: function(){
		if(self != top){
			top.location.href = self.location.href;
		}
	},
	methods: {
		refreshCode: function(){
			this.src = "captcha.jpg?t=" + $.now();
		},
		login: function (event) {
			var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
			$.ajax({
				type: "POST",
			    url: "sys/login",
			    data: data,
			    dataType: "json",
			    success: function(result){
					if(result.code == 0){//登录成功
						parent.location.href ='index.html';
					}else{
						vm.error = true;
						vm.errorMsg = result.msg;
						
						vm.refreshCode();
					}
				}
			});
		}
	}
});
</script>
</body>
</html>